/**
 * <p>Copyright: Copyright (c) 2014</p>
 * <p>Company: ---Technology Co. Ltd</p>
 * <p>2014-4-29</p>
 * @author Jan.Zhang
 */
package com.xianl.busiplat.po;

import java.io.Serializable;
import java.util.List;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;


/** 
 * desc:Module Model mapping db table:t_module
 * <p>author: Jan.Zhang </p>
 * date: 2014-4-29
 */
public class Module implements Serializable, Comparable<Module>{
	
	/**
	 * long:serialVersionUID 
	 */
	private static final long serialVersionUID = -3164376293486535694L;
	
	private Integer id;
	private String description;
	private String name;
	private Integer priority;
	private String url;
	private Integer parentId;
	private String servName;
	
	private List<Module> children = Lists.newArrayList();
	
	private Module parent;
	
	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}
	
	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}
	
	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}
	
	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * @return the priority
	 */
	public Integer getPriority() {
		return priority;
	}
	
	/**
	 * @param priority the priority to set
	 */
	public void setPriority(Integer priority) {
		this.priority = priority;
	}
	
	/**
	 * @return the url
	 */
	public String getUrl() {
		return url;
	}
	
	/**
	 * @param url the url to set
	 */
	public void setUrl(String url) {
		this.url = url;
	}
	
	/**
	 * @return the parentId
	 */
	public Integer getParentId() {
		return parentId;
	}
	
	/**
	 * @param parentId the parentId to set
	 */
	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}
	


	
	/**
	 * @return the servName
	 */
	public String getServName() {
		return servName;
	}

	
	/**
	 * @param servName the servName to set
	 */
	public void setServName(String servName) {
		this.servName = servName;
	}

	/**
	 * @return the children
	 */
	public List<Module> getChildren() {
		return children;
	}

	
	/**
	 * @param children the children to set
	 */
	public void setChildren(List<Module> children) {
		this.children = children;
	}
	
	
	/**
	 * @return the parent
	 */
	public Module getParent() {
		return parent;
	}

	
	/**
	 * @param parent the parent to set
	 */
	public void setParent(Module parent) {
		this.parent = parent;
	}

	public int compareTo(Module m) {
		if (m == null) {
			return -1;
		} else if (m == this) {
			return 0;
		} else if (this.priority < m.getPriority()) {
			return -1;
		} else if (this.priority > m.getPriority()) {
			return 1;
		}

		return 0;	
	}
	
	@Override
	public String toString() {
		return Objects.toStringHelper(this)
				.addValue(id)
				.addValue(name)
				.addValue(parent == null ? null:parent.getName())
				.addValue(children.size())
				.toString();
	}
	
}
